Repository navigation
Add Manila quota reads and logical-share inventory - #12
Merged
Mohammed Naser (mnaser) merged 1 commit intoDec 4, 2026
Merged
Conversation
Mohammed Naser (mnaser)
requested changes
Dec 3, 2026
Mohammed Naser (mnaser)
left a comment
Member
There was a problem hiding this comment.
The SQL work here is solid—the six raw quota queries cleanly preserve Manila's integer soft-delete (deleted = 0) and project vs share-type separation, and ShareGetInventory's single-pass window-function query mirrors Manila's Share.instance selection rules accurately.
A few items to clean up before we run CI and merge:
- Move the MariaDB integration tests into
tests/: Please movemanila/db/inventory_integration_test.goandmanila/db/quotas_integration_test.gointotests/so all integration tests live in one place (matching #10, #11, #13, and the rest of the repo, rather than reading../../tests/fixtures/...from insidemanila/db/). Keeping the_ "github.com/go-sql-driver/mysql"import ininternal/testutil/integration.gois fine either way. - Update the PR title and description to match the final code, and squash the two commits into one clean commit (keeping DCO sign-off). The title is currently the raw branch name (
Contrib/manila 2b3) and the description still mentions commit 1's scoped usage totals and Python SQL tests. - Move the detailed Manila quota and inventory docs from
README.mdintoAPI.md: Please keepREADME.mdto the package summary table entry (matching #13 and Designate #9) and place the detailed semantics and Manila-upgrade notes inAPI.md. - Minor nit: In
ShareGetInventory'sCASE flagged.statusranking inmanila/db/queries.sql, numbering the transitional ranks consecutively (closing the small 12 → 14 and 15 → 18 gaps) would make future Manila upgrade checks a bit clearer (regeneratesqlcif adjusted).
Add ShareGetInventory, which returns one row per nondeleted logical share, including shares without instances. It follows Manila's Share.instance rules (status precedence, active-replica preference and the replication-change exception) and takes status, availability zone and share type from one representative instance, chosen in a single pass with window functions. The transitional status ranking copies constants.TRANSITIONAL_STATUSES and must be re-checked on Manila upgrades. ShareGetAllWithInstances is unchanged. Add six read-only quota queries, named after the Manila DB API functions they follow, that read every project at once and return raw rows: - QuotaGetAllByProject, QuotaGetAllByProjectAndUser and QuotaGetAllByProjectAndShareType: project, user and share-type limit overrides from their separate tables. - QuotaClassGetDefault: limits of the persisted default quota class. - QuotaUsageGetAllByProject and QuotaUsageGetAllByProjectAndShareType: project and share-type usage rows from quota_usages, with nullable in_use and reserved returned as stored rather than summed. Rows with a NULL or empty project ID are excluded, and results are ordered by their identifying columns and row ID. The share-type queries left-join share_types, so limits and usage for deleted share types stay visible with a NULL name. Quota tables keep Manila's integer soft delete (deleted = 0 for active rows). Add the quota tables to the Manila schema fixture, unit tests, MariaDB integration tests in tests/ with inventory and quota fixtures, smoke calls in TestManilaQueries, and API.md documentation. Register the MySQL driver in the integration test helper. Co-authored-by: David Hulick <dave.hulick@gmail.com> Signed-off-by: David Hulick <dave.hulick@gmail.com> Signed-off-by: Jeremy Lee <jeremy.lee1664@gmail.com>
Jeremy Lee (legit-ninja)
force-pushed
the
contrib/manila-2b3
branch
from
December 3, 2026 18:06
b449e00 to
4a58ace
Compare
Mohammed Naser (mnaser)
approved these changes
Dec 4, 2026
Mohammed Naser (mnaser)
left a comment
Member
There was a problem hiding this comment.
Thanks for the updates—CI is green, approving and merging.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add a logical-share inventory query and six read-only quota queries to
manila/db.ShareGetInventory: one row per nondeleted logical share, with status, availability zone and share type taken from its representative instance.QuotaGetAllByProject,QuotaGetAllByProjectAndUser,QuotaGetAllByProjectAndShareType: project, user and share-type limit overrides.QuotaClassGetDefault: limits of the persisteddefaultquota class.QuotaUsageGetAllByProject,QuotaUsageGetAllByProjectAndShareType: project and share-type usage rows fromquota_usages.The quota queries are named after the Manila DB API functions they follow. Each reads every project at once and returns raw rows instead of a per-project dictionary.
Motivation
ShareGetAllWithInstancesreturns one row per share instance, so replicated or migrating shares appear more than once and their status depends on which row a consumer picks.ShareGetInventoryapplies Manila's ownShare.instancerules so consumers get one row per share with the status the Manila API reports.The quota reads expose Manila's persisted limits and usage separately, so consumers can resolve effective limits and reproduce Manila's totals without losing NULL or malformed rows.
Behavior
Share inventory
Share.instance: status precedence, active-replica preference and the replication-change exception. Instance ID breaks otherwise unspecified ties.is_soft_deletedshares stay in inventory; row-soft-deleted shares and instances are excluded.constants.TRANSITIONAL_STATUSESand must be re-checked on Manila upgrades.Quota accounting
in_useandreservedare returned as stored, including NULL. SummingQuotaUsageGetAllByProjectby project and resource reproduces Manila's_quota_usage_get_alltotals. Share-type usage describes the same allocations and must not be added to project totals.share_types, so limits and usage for deleted or missing share types stay visible with a NULL name.defaultclass, then service configuration.deleted = 0for active rows, the row ID for soft-deleted rows.Compatibility
The change is additive;
ShareGetAllWithInstancesand existing Manila queries are unchanged. The quota tables are added to the Manila schema fixture for tests and code generation; they are not production migrations.Tests and docs
TestManilaInventoryandTestManilaQuotas(MariaDB integration, intests/) with fixtures covering replication and revert cases, shares without instances, soft-deleted rows, NULL usage, usage-only projects and deleted share types.TestManilaQueries.API.md;README.mdonly updates themanila/dbsummary row.